<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" >
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8">


    <title>房间数据库</title>


    <!-- Bootstrap -->
    <!--<link href="/static/css/bootstrap.min.css" rel="stylesheet" media="screen">-->
    <!--<link href="/static/css/style_admin.css" rel="stylesheet" type="text/css">-->
    <!--<link type="text/css" rel="stylesheet" media="all" href="/static/css/global.css" />-->
    <!--<link type="text/css" rel="stylesheet" media="all" href="/static/css/global_color.css" />-->
    <link rel="stylesheet" href="/static/css/buttons.css">
    <!--<link href="http://cdn.bootcss.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">-->
    <!--<link rel="stylesheet" href="/static/css/reset.css">-->
    <!--<link rel="stylesheet" type="text/css" href="/static/css/default.css">-->
    <!--<link rel="stylesheet" href="/static/css/style.css">-->
    <link href="/static/css/stylesheets.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="/static/css/style_admin.css" rel="stylesheet" type="text/css">
    <link type="text/css" rel="stylesheet" media="all" href="/static/css/global.css" />
    <link type="text/css" rel="stylesheet" media="all" href="/static/css/global_color.css" />
    <link rel="stylesheet" href="/static/css/buttons.css">
    <link href="http://cdn.bootcss.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
    <!--[endif]-->
    <script src="/static/js/jquery-1.9.1.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="/static/js/html5shiv.js"></script>
    <script src="/static/js/respond.min.js"></script>
    <![endif]-->
    <!-- Javascript -->
    <script language="javascript" type="text/javascript">
    //删除房间数据
    $(document).ready(function(){
        $(".btn_delete").click(function () {
            $.post("/room/del_room/{{.UserID}}", {
                Id: $(".btn_delete").attr("Name"),
                Floor: "",
                RoomNum: ""
            }, function (result) {
                //console.log(result)
                if(result.RespCode == 200){
                    alert("删除成功");
                    location.reload();
                }else{
                    alert("删除失败");
                }
            });
        });

//        $(".btn_modify").click(function () {
//            location.href = "/room/update_room/"+$(".btn_delete").attr("Name");
//        });
    });

        //显示角色详细信息
        function showDetail(flag, a) {
            var detailDiv = a.parentNode.getElementsByTagName("div")[0];
            if (flag) {
                detailDiv.style.display = "block";
            }
            else
                detailDiv.style.display = "none";
        }

        //删除
        function deleteAdmin() {
            var r = window.confirm("确定要删除此床位吗？");
            document.getElementById("operate_result_info").style.display = "block";
        }
        //全选
        function selectAdmins(inputObj) {
            var inputArray = document.getElementById("datalist").getElementsByTagName("input");
            for (var i = 1; i < inputArray.length; i++) {
                if (inputArray[i].type == "checkbox") {
                    inputArray[i].checked = inputObj.checked;
                }
            }
        }
    </script>


</head>
<body>

<div class="header">
    <div class="logo">液位检测监控系统</div>

</div>

<div class="menu">

    <div class="breadLine">
        <div class="adminControl active">
            你好,{{.admin.UserName}}
        </div>
    </div>

    <ul class="navigation">
        <li>
            <a href="/admin/show_admin_index/{{.UserID}}">
                <span class="isw-bookmark" style="margin-top:5px;"></span>
                <span class="text">主界面</span>
            </a>
        </li>
        <li>
            <a  class="a-alert test" href="/admin/show_admins_list/{{.UserID}}">
                <span class="isw-user" style="margin-top:5px;"></span>
                <span class="text">用户数据库</span>
            </a>
        </li>
        <li>
            <a href="/admin/show_beds_list/{{.UserID}}">
                <span class="isw-documents" style="margin-top:5px;"></span>
                <span class="text">床位数据库</span>
            </a>
        </li>
        <li class="active">
            <a href="/admin/show_rooms_list/{{.UserID}}">
                <span class="isw-list" style="margin-top:5px;"></span>
                <span class="text">房间数据库</span>
            </a>
        </li>
        <li>
            <a href="/admin/show_departments_list/{{.UserID}}">
                <span class="isw-text-document" style="margin-top:5px;"></span>
                <span class="text">部门数据库</span>
            </a>
        </li>
        <li>
            <a href="/admin/index/{{.UserID}}">
                <span class="isw-graph" style="margin-top:5px;"></span>
                <span class="text">监控页面</span>
            </a>
        </li>
        <li>
            <a href="/admin/logout/{{.UserID}}">
                <span class="isw-cancel" style="margin-top:5px;"></span>
                <span class="text">退出系统</span>
            </a>
        </li>
    </ul>

    <div class="dr"><span></span></div>

    <div class="widget-fluid">
        <div id="menuDatepicker"></div>
    </div>

    <div class="dr"><span></span></div>

    <div class="widget-fluid">

        <div class="wBlock clearfix">
            <div class="dSpace">
                <h3>Last visits</h3>
                <span class="number">6,302</span>
                <span>5,774 <b>unique</b></span>
                <span>3,512 <b>returning</b></span>
            </div>
            <div class="rSpace">
                <h3>Today</h3>
                <span class="mChartBar" sparkType="bar" sparkBarColor="white"></span>
                <span>&nbsp;</span>
                <span>65% <b>New</b></span>
                <span>35% <b>Returning</b></span>
            </div>
        </div>

    </div>

</div>

<div class="content">

    <div class="workplace">
        <div class="head clearfix">
            <div class="isw-list" style="margin-top:7px;"></div>
            <h1>房间数据库</h1>
        </div>
        <div class="row-fluid">

            <div id="main-index">
                <div class="main-top">
                    <p>房间数据库</p>
                </div>
                <form action="" method="">
                    <!--查询-->
                    <div class="search_add">
                        <div>
                            <button type="button" class="button button-glow button-rounded button-raised button-primary" onclick="location.href='/room/add_room/{{.UserID}}';" /><i class="fa fa-plus" style="font-size:15px;"> 添加房间</i></button>
                        </div>
                        <div class="delete_btns">
                            <button class="button button-glow button-rounded button-raised button-primary"><i class="fa fa-trash-o" style="font-size:15px;">删除</i></button>
                        </div>
                    </div>
                    <!--删除和密码重置的操作提示-->
                    <div id="operate_result_info" class="operate_fail">
                        <img src="/static/img/close.png" onclick="this.parentNode.style.display='none';" />
                        <span>删除失败！数据并发错误。</span><!--密码重置失败！数据并发错误。-->
                    </div>
                    <!--数据区域：用表格展示数据-->
                    <div id="data">
                        <table id="datalist">
                            <tr>
                                <th class="th_select_all" style="width: 5%;">
                                    <input type="checkbox" onclick="selectAdmins(this);" />
                                    <span>全选</span>
                                </th>
                                <th style="width: 10%;">ID号</th>
                                <th style="width: 10%;">房间号</th>
                                <th style="width: 10%;">楼层</th>
                                <th style="width: 10%;">操作</th>
                            </tr>
                            {{range .rooms}}
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>{{.Id}}</td>
                                <td>{{.RoomNum}}</td>
                                <td>{{.Floor}}</td>
                                <td class="td_modi">
                                    <input type="button" value="修改" name="{{.Id}}" onclick="location.href='/room/update_room/{{$.UserID}}/{{.Id}}';" class="btn_modify" />
                                    <input type="button" value="删除" name="{{.Id}}" class="btn_delete" />
                                </td>
                            </tr>
                            {{end}}
                        </table>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<!-- Javascript -->
//批量删除
<script>
            $(document).ready(function() {

            $("#del_btn").click(function(){
            var objs = $(":input[type='checkbox'][name='checkbox']")
            var ids = {"Ids":[]};
                var num = objs.length

                for(var i=0;i< num;i++){
                    if(objs[i].checked == true){
                        console.log(objs[i].id)
                        ids.Ids.push(parseInt(objs[i].id))
                 }
             }
            if (ids.Ids.length <= 0){
                alert("选中一个你要删除的管理员");
                return false
            }

		            $.ajax({
                        url:'http://'+window.location.host+'/admin/del_admins,
                        type:"POST",
                        dataType:"json",
                        data:JSON.stringify(ids),
                        success: function(data){
                               if(data.RespCode == 205){
                                    alert("有帐号删除失败");
                                    window.location.reload()
                               }else if((data.RespCode == 200)){
                                    window.location.reload()
                               }
                        }
		            });
        });
});
</script>
</body>
</html>
